//#pragma long_calls
#include "../types.h"

#include "../call_func.h"

#include "../fe8func.h"

extern u32 text_font();

const
func call_text_font		=	(func)text_font;

#define	SOUL_FATE


#if defined(_HACK_MODULAR_)
static void*       sub_80040B8(void*a0,void*a1);
SECTION(".80040B8")
void*       sub_80040B8H(void*a0,void*a1){
    ROM_Call_func_2(a0,a1,sub_80040B8);
}
static
#endif

void*		sub_80040B8(void*a0,void*a1){
	struct{
		u8		u0_[4];
		u8*		u4_;
		void*	u8_;
		u8		uC_[4];
		u8		u10_[6];
		u8		u16_;
	}*p0;


	p0		=	*(void**)(0x2028E70);
	if(p0->u16_){
		/*内部函数*/
		return (void*)sub_800443C(a0,a1);
	}
	else{
#if 0
		u8*		buf;
		void*	font;
		buf		=	a1;

		font	=	call_text_font(a1,p0->u4_);
		buf		+=	2;
		sub_80D65C4(
				a0,
				font,
				p0->u8_
		);
#else
		//hack
		u32		codeA;
		u32		codeB;
		u8*		buf;
		buf		=	a1;
		codeA	=	buf[0];
		codeB	=	buf[1];
		buf+=2;

		if(codeA<0x81&&codeA>0x98&&codeB<0x80){
			codeA	=	0x83;
			codeB	=	0x9B;
		}
		codeA		-=	0x81;
		codeA		*=	0x80;
		codeB		-=	0x80;
		codeB		+=	codeA;		//偏移字数
		codeB		*=	0x54;		//字体大小
		sub_80D65C4(
				a0,
				codeB+p0->u4_,
				p0->u8_
		);
#endif
		return buf;
	}
}
